package com.zch.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.base.cache.serviceCache.CacheAdd;
import com.base.cache.serviceCache.CacheRemove;
import com.zch.dao.DeptMapper;
import com.zch.dao.model.Dept;
import com.zch.dao.model.DeptExample;
import com.zch.daoEx.DeptMapperEx;
import com.zch.daoEx.model.DeptEx;

@Service
public class DeptService {
	@Autowired
	private DeptMapper deptMapper;
	@Autowired
    private DeptMapperEx deptMapperEx;

	public int countByExample(DeptExample example) {
		return this.deptMapper.countByExample(example);
	}

	public Dept selectByPrimaryKey(String id) {
		return this.deptMapper.selectByPrimaryKey(id);
	}

	public List<Dept> selectByExample(DeptExample example) {
		return this.deptMapper.selectByExample(example);
	}

	public int deleteByPrimaryKey(String id) {
		return this.deptMapper.deleteByPrimaryKey(id);
	}

	public int updateByPrimaryKeySelective(Dept record) {
		return this.deptMapper.updateByPrimaryKeySelective(record);
	}

	public int updateByPrimaryKey(Dept record) {
		return this.deptMapper.updateByPrimaryKey(record);
	}

	public int deleteByExample(DeptExample example) {
		return this.deptMapper.deleteByExample(example);
	}

	public int updateByExampleSelective(Dept record, DeptExample example) {
		return this.deptMapper.updateByExampleSelective(record, example);
	}

	public int updateByExample(Dept record, DeptExample example) {
		return this.deptMapper.updateByExample(record, example);
	}

	public int insert(Dept record) {
		return this.deptMapper.insert(record);
	}

	public int insertSelective(Dept record) {
		return this.deptMapper.insertSelective(record);
	}

    public List<DeptEx> findDeptNo() {
        return this.deptMapperEx.findDeptNo();
        
    }

    public List<DeptEx> findDeptName(String id) {
        return this.deptMapperEx.findDeptName(id);
    }

    public List<DeptEx> selectAppList() {
        return this.deptMapperEx.selectAppList();
    }

    public String getNameByCode(String code){
    	DeptExample example = new DeptExample();
    	example.createCriteria().andDeptNoEqualTo(code);
    	List<Dept> list = deptMapper.selectByExample(example);
    	if (list.size() == 0) return "";
    	return list.get(0).getDeptName();
    }

    public List<DeptEx> selectList(Map<String, Object> map) {
        return this.deptMapperEx.selectList(map);
    }
}
